package org.realteam.example.servlet3;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns = { "/servlet3demo" })
public class Servlet3Demo extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

	public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		PrintWriter out = response.getWriter();
		String title = "Servlet 3 Demo";
		out.println("<HTML>");
		out.println("<HEAD><TITLE>" + title + "</TITLE></HEAD>");
		out.println("<BODY BGCOLOR=\"FDF5E6\">");
		out.println("Context Path:" + request.getContextPath() + "<br>");
		out.println("Server Info:" + request.getServletContext().getServerInfo());
		out.println("</BODY>");
		out.println("</HTML>");
		
	}
}
